import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

  {
    path: '/basic_setting',
    component: Layout,
    redirect: '/basic_setting/table',
    name: '基础设置',
    meta: { title: '基础设置', icon: 'example' },
    children: [
      {
        path: 'system_dictionary',
        name: '系统词典',
        component: () => import('@/views/basic_setting/system_dictionary'),
        meta: {title: '系统词典', icon: 'tree'},
      },
      {
        path: 'save_dictionary',
        name: '新增词典信息',
        component: () => import('@/views/basic_setting/save_dictionary'),
        meta: { title: '新增词典信息', icon: 'table' },
        hidden: true
      },
      {
        path: 'edit_dictionary/:id',
        name: '修改词典信息',
        component: () => import('@/views/basic_setting/save_dictionary'),
        meta: { title: '修改词典信息', icon: 'table' },
        hidden: true
      },
      {
        path: 'list',
        name: '驾驶员档案',
        component: () => import('@/views/basic_setting/driver_info'),
        meta: { title: '驾驶员档案', icon: 'table' },

      },
      {
        path: 'save',
        name: '添加驾驶员',
        component: () => import('@/views/basic_setting/driver_add'),
        meta: { title: '添加驾驶员', icon: 'tree' },
        hidden: true
      },
      {
        path: 'edit/:id',
        name: '修改驾驶员',
        component: () => import('@/views/basic_setting/driver_add'),
        meta: { title: '修改驾驶员', icon: 'tree' },
        hidden:true
      },
      {
        path: 'car_list',
        name: '车辆档案',
        component: () => import('@/views/basic_setting/car_list'),
        meta: { title: '车辆档案', icon: 'table' },
      },
      {
        path: 'car_add',
        name: '添加车辆',
        component: () => import('@/views/basic_setting/car_add'),
        meta: { title: '添加车辆', icon: 'tree' },
        hidden: true
      },
      {
        path: 'car_edit/:id',
        name: '修改车辆',
        component: () => import('@/views/basic_setting/car_add'),
        meta: { title: '修改车辆', icon: 'tree' },
        hidden:true
      },
      {
        hidden: true,
        path: 'car_imgPath/:id',
        name: '图片管理',
        component: () => import('@/views/basic_setting/car_img'),
        meta: { title: '图片管理', icon: 'tree' }
      },


      {
        path: 'unitlist',
        name: '往来单位',
        component: () => import('@/views/basic_setting/unitlist'),
        meta: { title: '往来单位', icon: 'table' },
      },
      {
        path: 'unitadd',
        name: '添加单位',
        component: () => import('@/views/basic_setting/unitadd'),
        meta: { title: '添加单位', icon: 'tree' },
        hidden:true
      },
      {
        path: 'unitedit/:id',
        name: '修改单位',
        component: () => import('@/views/basic_setting/unitadd'),
        meta: { title: '修改单位', icon: 'tree' },
        hidden:true
      }
    ]
  },

  {
    path: '/systemManager',
    component: Layout,
    redirect: '/systemManager/table',
    name: '系统设置',
    meta: { title: '系统设置', icon: 'example' },
    children: [

      {
        path: 'roleManager',
        name: '角色管理',
        component: () => import('@/views/system_settings/roleManager'),
        meta: { title: '角色管理', icon: 'table' }
      },
      {
        path: 'saverole',
        name: '添加角色',
        component: () => import('@/views/system_settings/saveAndUpdateRole'),
        meta: { title: '添加角色', icon: 'table' },
        hidden: true
      },

      {
        path: 'edit/:id',
        name: '修改角色',
        component: () => import('@//views/system_settings/saveAndUpdateRole'),  //-- 使用save页面 同一个页面做两件事情
        meta: { title: '修改角色', icon: 'tree' },
        hidden: true  //-- 隐藏 在页面上看不到这个菜单项
      },

      {
        path: 'userManager',
        name: '用户管理',
        component: () => import('@/views/system_settings/userList'),
        meta: { title: '用户管理', icon: 'table' }
      },
      {
        path: 'saveUser',
        name: '添加用户',
        component: () => import('@/views/system_settings/saveUser'),
        meta: { title: '添加用户', icon: 'table' },
        hidden: true
      },

      {
        path: 'passwordManager',
        name: '密码修改',
        component: () => import('@/views/system_settings/passwordManager'),
        meta: { title: '密码修改', icon: 'table' }
      },
      {
        path: 'updateUser/:id',
        name: '用户修改',
        component: () => import('@/views/system_settings/updateUser'),
        meta: { title: '用户修改', icon: 'table' },
        hidden: true
      },


      {
        path: 'authorization',
        name: '角色授权',
        component: () => import('@/views/system_settings/authorization'),
        meta: { title: '角色授权', icon: 'tree' },
        hidden: true
      }
    ]
  },


  {
    path: '/daily_work',
    component: Layout,
    redirect: '/daily_work/table',
    name: '日常处理',
    meta: { title: '日常处理', icon: 'example' },
    children: [
      {
        path: 'maintain_record',
        name: '保养记录',
        component: () => import('@/views/daily_work/maintain/maintain_record'),
        meta: { title: '保养记录', icon: 'table' },
      },
      {
        path: 'maintain_record_save',
        name: '新增保养记录',
        component: () => import('@/views/daily_work/maintain/maintain_record_save'),
        meta: { title: '新增保养记录', icon: 'table' },
        hidden: true
      },
      {
        path: 'maintain_record_update/:id',
        name: '修改保养记录',
        component: () => import('@/views/daily_work/maintain/maintain_record_update'),
        meta: { title: '修改保养记录', icon: 'table' },
        hidden: true
      },
      {
        path: 'violation_record',
        name: '违章记录',
        component: () => import('@/views/daily_work/violation/violation_record'),
        meta: { title: '违章记录', icon: 'tree' }
      },
      {
        path: 'driving_licence_update/:id',
        name: '修改违章记录',
        component: () => import('@/views/daily_work/violation/driving_licence_update'),
        meta: { title: '修改违章记录', icon: 'tree' },
        hidden: true
      },
      {
        path: 'driving_licence_save',
        name: '新增违章记录',
        component: () => import('@/views/daily_work/violation/driving_licence_save'),
        meta: { title: '新增违章记录', icon: 'tree' },
        hidden: true
      },

      {
        path: 'insurancelist',
        name: '保险记录',
        component: () => import('@/views/daily_work/insurancelist'),
        meta: { title: '保险记录', icon: 'table' }
      },
      {
        path: 'insuranceadd',
        name: '保险添加',
        component: () => import('@/views/daily_work/insuranceadd'),
        meta: { title: '保险添加', icon: 'tree' },
        hidden:true
      },
      {
        path: 'insuranceedit/:id',
        name: '保险修改',
        component: () => import('@/views/daily_work/insuranceedit'),
        meta: { title: '保险修改', icon: 'tree' },
        hidden:true
      },
      {
        path: 'refuelinglist',
        name: '加油记录',
        component: () => import('@/views/daily_work/refuelinglist'),
        meta: { title: '加油记录', icon: 'table' }
      },
      {
        path: 'refuelingadd',
        name: '加油添加',
        component: () => import('@/views/daily_work/refuelingadd'),
        meta: { title: '加油添加', icon: 'tree' },
        hidden:true
      },
      {
        path: 'refuelingedit/:id',
        name: '加油修改',
        component: () => import('@/views/daily_work/refuelingedit'),
        meta: { title: '加油修改', icon: 'tree' },
        hidden:true
      },
      {
        path: 'repair_record',
        name: '维修记录',
        component: () => import('@/views/daily_work/repair_record/repair_record'),
        meta: { title: '维修记录', icon: 'tree' },
      },
      {
        path: 'add_repair_record',
        name: '维修信息登记',
        component: () => import('@/views/daily_work/repair_record/add_repair_record'),
        meta: { title: '维修信息登记', icon: 'tree' },
        hidden: true
      },
      {
        path: 'add_get_car_record/:id',
        name: '取车信息登记',
        component: () => import('@/views/daily_work/repair_record/add_get_car_record'),
        meta: { title: '取车信息登记  ', icon: 'tree' },
        hidden: true
      },
      {
        path: 'edit_repair_record/:id',
        name: '维修信息修改',
        component: () => import('@/views/daily_work/repair_record/add_repair_record'),
        meta: { title: '维修信息修改  ', icon: 'tree' },
        hidden: true
      },
      {
        path: 'detail_repair_record/:id',
        name: '详细信息',
        component: () => import('@/views/daily_work/repair_record/detail_repair_record'),
        meta: {title: '详细信息  ', icon: 'tree'},
        hidden: true
      },
      {
        path: 'fees_record',
        name: '规费记录',
        component: () => import('@/views/daily_work/fees_record/fees_record'),
        meta: { title: '规费记录', icon: 'tree' },

      },
      {
        path: 'add_fees_record',
        name: '规费信息登记',
        component: () => import('@/views/daily_work/fees_record/add_fees_record'),
        meta: {title: '规费信息登记', icon: 'tree'},
        hidden: true
      },
      {
        path: 'edit_fee_record/:id',
        name: '规费信息修改',
        component: () => import('@/views/daily_work/fees_record/add_fees_record'),
        meta: {title: '规费信息修改', icon: 'tree'},
        hidden: true
      },
      {
        path: 'inspection',
        name: '年检记录',
        component: () => import('@/views/daily_work/inspection'),
        meta: { title: '年检记录', icon: 'table' },

      },
      {
        path: 'addInspection',
        name: '年检信息登记',
        component: () => import('@/views/daily_work/addInspection'),
        meta: { title: '年检记录登记', icon: 'table' },
        hidden: true

      },
      {
        path: 'updateInspection/:id',
        name: '年检信息修改',
        component: () => import('@/views/daily_work/updateInspection'),
        meta: { title: '年检记录修改', icon: 'table' },
        hidden: true

      },
      {
        path: 'accident_record_list',
        name: '事故记录',
        component: () => import('@/views/daily_work/accident_record_list'),
        meta: { title: '事故记录列表', icon: 'table' },
      },
      {
        path: 'accident_record_add',
        name: '添加事故记录',
        component: () => import('@/views/daily_work/accident_record_save'),
        meta: { title: '添加事故记录', icon: 'add' },
        hidden: true,
      },
      {
        path: `accident_record_edit/:id`,
        name: '修改事故记录',
        component: () => import('@/views/daily_work/accident_record_save'),
        meta: { title: '修改事故记录', icon: 'update' },
        hidden: true,
      },
      {
      path: 'driving_record',
        name: '出车记录',
        component: () => import('@/views/daily_work/driving_record'),
        meta: { title: '出车记录', icon: 'tree' },
},
      {
        path: 'driving_record_add',
        name: '添加记录',
        component: () => import('@/views/daily_work/driving_record_add'),
        meta: { title: '添加记录', icon: 'tree' },
        hidden: true,
      },
      {
        path: 'driving_record_add/:id',
        name: '修改记录',
        component: () => import('@/views/daily_work/driving_record_add'),
        meta: { title: '修改记录', icon: 'tree' },
        hidden: true,
      },
      {
        path: 'driving_record_info/:id',
        name: '出车详细',
        component: () => import('@/views/daily_work/driving_record_info'),
        meta: { title: '出车详细', icon: 'tree' },
        hidden: true,
      },
      {
        path: 'driving_record_back/:id',
        name: ' 添加回车信息',
        component: () => import('@/views/daily_work/driving_record_back'),
        meta: { title: '回车信息', icon: 'tree' },
        hidden: true,
      },
    ]
  },
  {
    path: '/expiration_reminder',
    component: Layout,
    redirect: '/expiration_reminder/remind',
    name: '到期提醒',
    meta: { title: '到期提醒', icon: 'example' },
    children: [
      {
        path: 'remind',
        name: '到期提醒',
        component: () => import('@/views/expiration_reminder/remind'),
        meta: { title: '到期提醒', icon: 'table' }
      }
    ]
  },
  {
    path: '/example2',
    component: Layout,
    redirect: '/example/table',
    name: 'Example2',
    meta: { title: '车辆状态', icon: 'example' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: 'Table', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: 'Tree', icon: 'tree' }
      }
    ]
  },


  {
    path: '/report_center',
    component: Layout,
    redirect: '/report_center/bar',
    name:`报表中心`,
    meta: { title: '报表中心', icon: 'example' },
    children: [
      {
        path: 'bar',
        component: () => import('@/views/report_center/bar'),
        meta: { title: '柱状图', icon: 'form' }
      },
      {
        path: 'pie',
        component: () => import('@/views/report_center/pie'),
        meta: { title: '饼状图', icon: 'form' }
      }
    ]
  },

  // {
  //   path: '/nested',
  //   component: Layout,
  //   redirect: '/nested/menu1',
  //   name: 'Nested',
  //   meta: {
  //     title: 'nested',
  //     icon: 'nested'
  //   },
  //   children: [
  //     {
  //       path: 'menu1',
  //       component: () => import('@/views/nested/menu1/index'), // Parent router-view
  //       name: 'Menu1',
  //       meta: { title: 'menu1' },
  //       children: [
  //         {
  //           path: 'menu1-1',
  //           component: () => import('@/views/nested/menu1/menu1-1'),
  //           name: 'Menu1-1',
  //           meta: { title: 'menu1-1' }
  //         },
  //         {
  //           path: 'menu1-2',
  //           component: () => import('@/views/nested/menu1/menu1-2'),
  //           name: 'Menu1-2',
  //           meta: { title: 'menu1-2' },
  //           children: [
  //             {
  //               path: 'menu1-2-1',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
  //               name: 'Menu1-2-1',
  //               meta: { title: 'menu1-2-1' }
  //             },
  //             {
  //               path: 'menu1-2-2',
  //               component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
  //               name: 'Menu1-2-2',
  //               meta: { title: 'menu1-2-2' }
  //             }
  //           ]
  //         },
  //         {
  //           path: 'menu1-3',
  //           component: () => import('@/views/nested/menu1/menu1-3'),
  //           name: 'Menu1-3',
  //           meta: { title: 'menu1-3' }
  //         }
  //       ]
  //     },
  //     {
  //       path: 'menu2',
  //       component: () => import('@/views/nested/menu2/index'),
  //       meta: { title: 'menu2' }
  //     }
  //   ]
  // },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
